#define xuser mixc::talk_about_reflect::inc
#include"io/tty.hpp"
#include"dumb/secret_type.hpp"
#include"macro/xtypeid.hpp"
#include"chrono/date.hpp"
#include"chrono/now.hpp"
#include"mixc.hpp"

xstruct(
    xname(bar),
    xpubf(sex, xuser::secret_type<char>),
    xpubf(s_number, xuser::secret_type<int>[2])
) $

xstruct(
    xname(barx),
    xpubf(number, int[2])
) $

xstruct(
    xname(foo),
    xpubb(barx),
    xpubf(bar, bar),
    xpubf(age, xuser::secret_type<i32>),
    xpubf(name, asciis)
) $

using namespace xuser;

xinit(xuser::the_main){
    secret_type<foo> secret_foo;
    ::foo normal_foo;
    normal_foo.number[0] = 0;
    normal_foo.number[1] = 1;
    normal_foo.bar.s_number[0] = 2;
    normal_foo.bar.s_number[1] = 3;
    normal_foo.bar.sex   = 'M';
    normal_foo.age       = 24;
    normal_foo.name      = "cat";

    secret_foo.number[0] = 0;
    secret_foo.number[1] = 1;
    secret_foo.bar.s_number[0] = 2;
    secret_foo.bar.s_number[1] = 3;
    secret_foo.bar.sex   = 'M';
    secret_foo.age       = 24;
    secret_foo.name      = "cat";

    tty.write_line("normal_foo:");
    tty.write_line(normal_foo, xlocal_endl);

    tty.write_line("no_secret normal_foo:");
    tty.write_line_non_secret(normal_foo, xlocal_endl);

    tty.write_line("secret_foo:");
    tty.write_line(secret_foo, xlocal_endl);

    tty.write_line("no_secret secret_foo:");
    tty.write_line_non_secret(secret_foo, xlocal_endl);


    tty.write_line("normal_foo:");
    tty.xreflect_line(normal_foo);
    tty.write_line();

    tty.write_line("no_secret normal_foo:");
    tty.xreflect_line_non_secret(normal_foo);
    tty.write_line();

    tty.write_line("secret_foo:");
    tty.xreflect_line(secret_foo);
    tty.write_line();

    tty.write_line("no_secret secret_foo:");
    tty.xreflect_line_non_secret("no_secret", secret_foo);
    tty.write_line();

    xtypeid(foo).foreach_fields(normal_foo, [](asciis name, auto const & value){
        tty.write_line(name, ':', value);
    });

    date today = now;
    xhint("hello world", today);
};
